package org.htmlparser.parserapplications.filterbuilder.wrappers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Locale;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JTextArea;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import org.htmlparser.Node;
import org.htmlparser.NodeFilter;
import org.htmlparser.Parser;
import org.htmlparser.filters.StringFilter;
import org.htmlparser.parserapplications.filterbuilder.Filter;

public class StringFilterWrapper extends Filter
  implements ActionListener, DocumentListener, Runnable
{
  protected static Locale[] mLocales = null;
  protected JCheckBox mCaseSensitivity;
  protected StringFilter mFilter = new StringFilter();
  protected JComboBox mLocale;
  protected JTextArea mPattern;

  // ERROR //
  public StringFilterWrapper()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 27	org/htmlparser/parserapplications/filterbuilder/Filter:<init>	()V
    //   4: aload_0
    //   5: new 29	org/htmlparser/filters/StringFilter
    //   8: dup
    //   9: invokespecial 30	org/htmlparser/filters/StringFilter:<init>	()V
    //   12: putfield 32	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mFilter	Lorg/htmlparser/filters/StringFilter;
    //   15: aload_0
    //   16: getfield 32	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mFilter	Lorg/htmlparser/filters/StringFilter;
    //   19: iconst_1
    //   20: invokevirtual 36	org/htmlparser/filters/StringFilter:setCaseSensitive	(Z)V
    //   23: aload_0
    //   24: new 38	javax/swing/JTextArea
    //   27: dup
    //   28: iconst_2
    //   29: bipush 20
    //   31: invokespecial 41	javax/swing/JTextArea:<init>	(II)V
    //   34: putfield 43	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mPattern	Ljavax/swing/JTextArea;
    //   37: aload_0
    //   38: getfield 43	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mPattern	Ljavax/swing/JTextArea;
    //   41: new 45	javax/swing/border/BevelBorder
    //   44: dup
    //   45: iconst_1
    //   46: invokespecial 48	javax/swing/border/BevelBorder:<init>	(I)V
    //   49: invokevirtual 52	javax/swing/JTextArea:setBorder	(Ljavax/swing/border/Border;)V
    //   52: aload_0
    //   53: aload_0
    //   54: getfield 43	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mPattern	Ljavax/swing/JTextArea;
    //   57: invokevirtual 56	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:add	(Ljava/awt/Component;)Ljava/awt/Component;
    //   60: pop
    //   61: aload_0
    //   62: getfield 43	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mPattern	Ljavax/swing/JTextArea;
    //   65: invokevirtual 60	javax/swing/JTextArea:getDocument	()Ljavax/swing/text/Document;
    //   68: aload_0
    //   69: invokeinterface 66 2 0
    //   74: aload_0
    //   75: getfield 43	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mPattern	Ljavax/swing/JTextArea;
    //   78: aload_0
    //   79: getfield 32	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mFilter	Lorg/htmlparser/filters/StringFilter;
    //   82: invokevirtual 70	org/htmlparser/filters/StringFilter:getPattern	()Ljava/lang/String;
    //   85: invokevirtual 74	javax/swing/JTextArea:setText	(Ljava/lang/String;)V
    //   88: aload_0
    //   89: new 76	javax/swing/JCheckBox
    //   92: dup
    //   93: ldc 78
    //   95: invokespecial 80	javax/swing/JCheckBox:<init>	(Ljava/lang/String;)V
    //   98: putfield 82	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mCaseSensitivity	Ljavax/swing/JCheckBox;
    //   101: aload_0
    //   102: aload_0
    //   103: getfield 82	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mCaseSensitivity	Ljavax/swing/JCheckBox;
    //   106: invokevirtual 56	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:add	(Ljava/awt/Component;)Ljava/awt/Component;
    //   109: pop
    //   110: aload_0
    //   111: getfield 82	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mCaseSensitivity	Ljavax/swing/JCheckBox;
    //   114: aload_0
    //   115: invokevirtual 86	javax/swing/JCheckBox:addActionListener	(Ljava/awt/event/ActionListener;)V
    //   118: aload_0
    //   119: getfield 82	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mCaseSensitivity	Ljavax/swing/JCheckBox;
    //   122: aload_0
    //   123: getfield 32	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mFilter	Lorg/htmlparser/filters/StringFilter;
    //   126: invokevirtual 90	org/htmlparser/filters/StringFilter:getCaseSensitive	()Z
    //   129: invokevirtual 93	javax/swing/JCheckBox:setSelected	(Z)V
    //   132: aload_0
    //   133: new 95	javax/swing/JComboBox
    //   136: dup
    //   137: invokespecial 96	javax/swing/JComboBox:<init>	()V
    //   140: putfield 98	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mLocale	Ljavax/swing/JComboBox;
    //   143: aload_0
    //   144: getfield 98	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mLocale	Ljavax/swing/JComboBox;
    //   147: astore_3
    //   148: aload_3
    //   149: monitorenter
    //   150: aload_0
    //   151: getfield 98	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mLocale	Ljavax/swing/JComboBox;
    //   154: aload_0
    //   155: getfield 32	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mFilter	Lorg/htmlparser/filters/StringFilter;
    //   158: invokevirtual 102	org/htmlparser/filters/StringFilter:getLocale	()Ljava/util/Locale;
    //   161: invokevirtual 107	java/util/Locale:getDisplayName	()Ljava/lang/String;
    //   164: invokevirtual 111	javax/swing/JComboBox:addItem	(Ljava/lang/Object;)V
    //   167: new 113	java/lang/Thread
    //   170: dup
    //   171: aload_0
    //   172: invokespecial 116	java/lang/Thread:<init>	(Ljava/lang/Runnable;)V
    //   175: astore 5
    //   177: aload 5
    //   179: ldc 118
    //   181: invokevirtual 121	java/lang/Thread:setName	(Ljava/lang/String;)V
    //   184: aload 5
    //   186: iconst_1
    //   187: invokevirtual 124	java/lang/Thread:setPriority	(I)V
    //   190: aload 5
    //   192: invokevirtual 127	java/lang/Thread:run	()V
    //   195: aload_3
    //   196: monitorexit
    //   197: aload_0
    //   198: aload_0
    //   199: getfield 98	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mLocale	Ljavax/swing/JComboBox;
    //   202: invokevirtual 56	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:add	(Ljava/awt/Component;)Ljava/awt/Component;
    //   205: pop
    //   206: aload_0
    //   207: getfield 98	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mLocale	Ljavax/swing/JComboBox;
    //   210: aload_0
    //   211: invokevirtual 128	javax/swing/JComboBox:addActionListener	(Ljava/awt/event/ActionListener;)V
    //   214: aload_0
    //   215: getfield 98	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mLocale	Ljavax/swing/JComboBox;
    //   218: iconst_0
    //   219: invokevirtual 131	javax/swing/JComboBox:setSelectedIndex	(I)V
    //   222: aload_0
    //   223: getfield 98	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mLocale	Ljavax/swing/JComboBox;
    //   226: astore 7
    //   228: aload_0
    //   229: getfield 32	org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper:mFilter	Lorg/htmlparser/filters/StringFilter;
    //   232: invokevirtual 90	org/htmlparser/filters/StringFilter:getCaseSensitive	()Z
    //   235: ifne +21 -> 256
    //   238: iconst_1
    //   239: istore 8
    //   241: aload 7
    //   243: iload 8
    //   245: invokevirtual 134	javax/swing/JComboBox:setVisible	(Z)V
    //   248: return
    //   249: astore 4
    //   251: aload_3
    //   252: monitorexit
    //   253: aload 4
    //   255: athrow
    //   256: iconst_0
    //   257: istore 8
    //   259: goto -18 -> 241
    //
    // Exception table:
    //   from	to	target	type
    //   150	197	249	finally
    //   251	253	249	finally
  }

  public boolean accept(Node paramNode)
  {
    return this.mFilter.accept(paramNode);
  }

  public void actionPerformed(ActionEvent paramActionEvent)
  {
    boolean bool1 = false;
    Object localObject1 = paramActionEvent.getSource();
    if (localObject1 == this.mCaseSensitivity)
    {
      boolean bool2 = this.mCaseSensitivity.isSelected();
      this.mFilter.setCaseSensitive(bool2);
      JComboBox localJComboBox2 = this.mLocale;
      if (!(bool2))
        bool1 = true;
      localJComboBox2.setVisible(bool1);
      this.mLocale.setSelectedItem(this.mFilter.getLocale().getDisplayName());
    }
    do
      return;
    while (localObject1 != this.mLocale);
    while (true)
    {
      int i;
      synchronized (this.mLocale)
      {
        Object[] arrayOfObject = this.mLocale.getSelectedObjects();
        if ((arrayOfObject != null) && (arrayOfObject.length != 0))
        {
          String str = (String)arrayOfObject[0];
          i = 0;
          if (i < mLocales.length)
          {
            if (!(str.equals(mLocales[i].getDisplayName())))
              break label175;
            this.mFilter.setLocale(mLocales[i]);
            label175: break label175:
          }
        }
      }
    }
  }

  public void changedUpdate(DocumentEvent paramDocumentEvent)
  {
  }

  public String getDescription()
  {
    return "Nodes containing string";
  }

  public String getIconSpec()
  {
    return "images/StringFilter.gif";
  }

  public NodeFilter getNodeFilter()
  {
    StringFilter localStringFilter = new StringFilter();
    localStringFilter.setCaseSensitive(this.mFilter.getCaseSensitive());
    localStringFilter.setLocale(this.mFilter.getLocale());
    localStringFilter.setPattern(this.mFilter.getPattern());
    return localStringFilter;
  }

  public NodeFilter[] getSubNodeFilters()
  {
    return new NodeFilter[0];
  }

  public void insertUpdate(DocumentEvent paramDocumentEvent)
  {
    Document localDocument = paramDocumentEvent.getDocument();
    try
    {
      this.mFilter.setPattern(localDocument.getText(0, localDocument.getLength()));
      return;
    }
    catch (BadLocationException localBadLocationException)
    {
      localBadLocationException.printStackTrace();
    }
  }

  public void removeUpdate(DocumentEvent paramDocumentEvent)
  {
    Document localDocument = paramDocumentEvent.getDocument();
    try
    {
      this.mFilter.setPattern(localDocument.getText(0, localDocument.getLength()));
      return;
    }
    catch (BadLocationException localBadLocationException)
    {
      localBadLocationException.printStackTrace();
    }
  }

  public void run()
  {
    while (true)
    {
      int i;
      synchronized (this.mLocale)
      {
        mLocales = Locale.getAvailableLocales();
        String str = this.mFilter.getLocale().getDisplayName();
        i = 0;
        if (i < mLocales.length)
        {
          if (str.equals(mLocales[i].getDisplayName()))
            break label86;
          this.mLocale.addItem(mLocales[i].getDisplayName());
          break label86:
        }
        this.mLocale.invalidate();
        label86: return;
      }
    }
  }

  public void setNodeFilter(NodeFilter paramNodeFilter, Parser paramParser)
  {
    boolean bool;
    this.mFilter = ((StringFilter)paramNodeFilter);
    this.mPattern.setText(this.mFilter.getPattern());
    this.mCaseSensitivity.setSelected(this.mFilter.getCaseSensitive());
    JComboBox localJComboBox = this.mLocale;
    if (!(this.mFilter.getCaseSensitive()))
      bool = true;
    while (true)
    {
      localJComboBox.setVisible(bool);
      this.mLocale.setSelectedItem(this.mFilter.getLocale().getDisplayName());
      return;
      bool = false;
    }
  }

  public void setSubNodeFilters(NodeFilter[] paramArrayOfNodeFilter)
  {
  }

  public String toJavaCode(StringBuffer paramStringBuffer, int[] paramArrayOfInt)
  {
    String str2;
    StringBuffer localStringBuffer = new StringBuffer().append("filter");
    int i = paramArrayOfInt[1];
    paramArrayOfInt[1] = (i + 1);
    String str1 = i;
    spaces(paramStringBuffer, paramArrayOfInt[0]);
    paramStringBuffer.append("StringFilter ");
    paramStringBuffer.append(str1);
    paramStringBuffer.append(" = new StringFilter ();");
    newline(paramStringBuffer);
    spaces(paramStringBuffer, paramArrayOfInt[0]);
    paramStringBuffer.append(str1);
    paramStringBuffer.append(".setCaseSensitive (");
    if (this.mFilter.getCaseSensitive())
      str2 = "true";
    while (true)
    {
      paramStringBuffer.append(str2);
      paramStringBuffer.append(");");
      newline(paramStringBuffer);
      spaces(paramStringBuffer, paramArrayOfInt[0]);
      paramStringBuffer.append(str1);
      paramStringBuffer.append(".setLocale (new java.util.Locale (\"");
      paramStringBuffer.append(this.mFilter.getLocale().getLanguage());
      paramStringBuffer.append("\", \"");
      paramStringBuffer.append(this.mFilter.getLocale().getCountry());
      paramStringBuffer.append("\", \"");
      paramStringBuffer.append(this.mFilter.getLocale().getVariant());
      paramStringBuffer.append("\"));");
      newline(paramStringBuffer);
      spaces(paramStringBuffer, paramArrayOfInt[0]);
      paramStringBuffer.append(str1);
      paramStringBuffer.append(".setPattern (\"");
      paramStringBuffer.append(this.mFilter.getPattern());
      paramStringBuffer.append("\");");
      newline(paramStringBuffer);
      return str1;
      str2 = "false";
    }
  }
}